<?php
session_start();
include('input.php');
$input = new input();

include('db.php');
$act = $input->get('act');
if ($act != false) {
    $username = $input->post('username');
    $password = $input->post('password');
    $sql="SELECT * from user WHERE username='{$username}' and password='{$password}'";
    $mysqli_result=$mysqli->query($sql);//所有用户数据取出

    if ($row=$mysqli_result->fetch_array()) {
        $_SESSION['username'] = $row['username'];//将数据放在 session 里面
        //user_id,过期时间
        // 跳转的时候不能输出
        header("Location:http://localhost:8888/untitled/practice.php");//跳转到留言页
    } else {
        echo "登录失败";exit;
    }
}


?>

<!doctype html>

<html>
<head>
    <meta charset='utf-8'/>
    <title>管理员登录</title>
</head>
<body>
<form action="http://localhost:8888/untitled/login.php?act=chjk" method="post">
    <input type='text' name='username' title="输入用户名">
    <input type='password' name='password' title="输入密码">
    <input type='submit' value='点击登录'>
</form>
</body>
</html>

